WRANGLERS
Photo by Matt Collamer on Unsplash
Everything will be okay in the end. If it’s not okay, it’s not the end…
— John Lennon
url_root <- "https://raw.githubusercontent.com/UN-AVT/kamino-source/main/sources/0-shared/data/"
url_file <- "road-to-recovery/road-to-recovery.csv"
url <- paste0(url_root, url_file)
df <- read.csv(url, header = TRUE, stringsAsFactors = FALSE)
df
df <- df[-12,]
colnames(df)[1] <- "country" # Changing Column Name
df$Mobility.Rate<-as.numeric(gsub("\\%","",df$Mobility.Rate)) # Removin percent sign
df$Recovery.Rate<-as.numeric(gsub("\\%","",df$Recovery.Rate))
df$Total.Cases<-as.numeric(gsub("\\,","",df$Total.Cases))
df$Total.Recovered<-as.numeric(gsub("\\,","",df$Total.Recovered))
library(countrycode)
df$iso <- tolower(countrycode(sourcevar = df[, "country"],
origin = "country.name",
destination = "iso2c"))
df
theme_opts <- theme(
text = element_text(family = "inconsolata"),
plot.title = element_text(color = "black", size = 20, face = "bold"),
plot.subtitle = element_text(color = "black", size = 15),
plot.caption = element_text(color = "#555555", size = 8),
axis.text = element_text(size=10),
panel.border = element_blank(),
panel.background = element_blank(),
legend.title = element_text(color = "black", size = 8, face = "bold"),
legend.text = element_text(color = "black", size = 8),
legend.position = "none"
)
v1 <- ggplot(df, aes(x=Recovery.Rate, y=Mobility.Rate, country = iso, label=country)) +
annotate("rect", xmin = 0, xmax = 50, ymin = -50, ymax = 20, fill= "white", color = "white") +
annotate("rect", xmin = 50, xmax = 100, ymin = -50, ymax = 20, fill= "#c3e8ee", color = "white") +
annotate("rect", xmin = 0, xmax = 50, ymin = -120, ymax = -50, fill= "#f3d4d9", color = "white") +
annotate("rect", xmin = 50, xmax = 100, ymin = -120, ymax = -50, fill= "white", color = "white")+
annotate("text", x = 60, y=15, label= "High Mobility, High recovery\nLifted Restrictions &\nPeople going back to work")+
annotate("text", x = 10, y=-60, label= "Low Mobility, Low recovery\nRemaining Indoors") +
annotate("text", x = 10, y=15, label= "High Mobility, Low recovery\nAllowing activity\nPossible surge in Future") +
annotate("text", x = 60, y=-115, label= "Low Mobility, High recovery\nPlaying it Safe") +
geom_point() +
geom_flag()+
geom_text_repel() +
scale_y_continuous(breaks=c(20, 0, -40, -80, -120),
labels=c('20%', '0', '-40%', '-80%', '-12%')) +
scale_x_continuous(breaks=c(0, 25, 50, 75, 100),
labels=c('0', '25%', '50%', '75%', '100%'))+
labs(y="Mobility Rate",
x = "Recovery Rate",
title = "The Road to Recovery",
subtitle = "Which Economies are Reopening? \nThe higher the mobility rate, the more activity this signifies")+
theme_opts
girafe(ggobj = v1, width_svg = 16, height_svg = 15,
options = list(opts_sizing(rescale = TRUE, width = 0.8)))